package com.alf.admin.controller.v1;

import com.alf.admin.service.AdChannelService;
import com.alf.model.admin.dtos.ChannelDto;
import com.alf.model.admin.pojos.AdChannel;
import com.alf.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Alf_Chou
 * version1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {
    @Autowired
    private AdChannelService adChannelService;

    /**
     * 根据名称分页查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto) {
        return adChannelService.findByNameAndPage(dto);
    }

    /**
     * 新增
     * @param channel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdChannel channel) {
        return adChannelService.insert(channel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adChannelService.update(adChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }



}
